package edu.guet.server.mapper;

import edu.guet.server.model.Stu;
import edu.guet.server.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {
    User login(User data);//用户登录

    User getUserByPhonenum(String phone_num);//根据手机号和学号获取用户

    @Insert("insert into guet_db.user (username,password,user_type,phone_num,email,university_name)\n" +
            "values ( #{username},#{password},#{user_type},#{phone_num},#{email},#{university_name})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int register(User data);//用户注册

    //根据user_id获取user
    User getUserById(int id);


    @Select("SELECT * from user where phone_num=#{phoneNum} or email=#{email}")
    User findUserByNameorEmail(String phoneNum, String email);

    List<User> findUsersByIds(List<Integer> userIds);

    void addStu(User user);

    User getUserByStuNumber(String stuNumber);

    User getUser(Integer techId);

    void updateUser(User user);

    List<Integer> getUserIdsByNum(List<String> stuNums);

    void updateSemStuId(User data);

    List<Stu> getStulistBynumber(List<Stu> stus);
}
